home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / widget / nsITextWidget.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  6KB  |  195 lines

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is mozilla.org code.
  16.  *
  17.  * The Initial Developer of the Original Code is
  18.  * Netscape Communications Corporation.
  19.  * Portions created by the Initial Developer are Copyright (C) 1998
  20.  * the Initial Developer. All Rights Reserved.
  21.  *
  22.  * Contributor(s):
  23.  *
  24.  * Alternatively, the contents of this file may be used under the terms of
  25.  * either the GNU General Public License Version 2 or later (the "GPL"), or
  26.  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27.  * in which case the provisions of the GPL or the LGPL are applicable instead
  28.  * of those above. If you wish to allow use of your version of this file only
  29.  * under the terms of either the GPL or the LGPL, and not to allow others to
  30.  * use your version of this file under the terms of the MPL, indicate your
  31.  * decision by deleting the provisions above and replace them with the notice
  32.  * and other provisions required by the GPL or the LGPL. If you do not delete
  33.  * the provisions above, a recipient may use your version of this file under
  34.  * the terms of any one of the MPL, the GPL or the LGPL.
  35.  *
  36.  * ***** END LICENSE BLOCK ***** */
  37. #ifndef nsITextWidget_h__
  38. #define nsITextWidget_h__
  39.  
  40. #include "nsIWidget.h"
  41. #include "nsString.h"
  42.  
  43. // {F8030011-C342-11d1-97F0-00609703C14E}
  44. #define NS_ITEXTWIDGET_IID \
  45. { 0xf8030011, 0xc342, 0x11d1, { 0x97, 0xf0, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } }
  46.  
  47.  
  48. struct nsTextWidgetInitData : public nsWidgetInitData {
  49.   nsTextWidgetInitData()
  50.     : mIsPassword(PR_FALSE),
  51.       mIsReadOnly(PR_FALSE)
  52.   {
  53.   }
  54.  
  55.   PRBool mIsPassword;
  56.   PRBool mIsReadOnly;
  57. };
  58.  
  59.  
  60. /**
  61.  *
  62.  * Single line text editor. 
  63.  * Unlike a nsIWidget, The text editor must automatically clear 
  64.  * itself to the background color when paint messages are generated.
  65.  *
  66.  */
  67.  
  68. class nsITextWidget : public nsISupports
  69. {
  70.  
  71.   public:
  72.     NS_DEFINE_STATIC_IID_ACCESSOR(NS_ITEXTWIDGET_IID)
  73.  
  74.     /**
  75.      * Get the text of this component.
  76.      *
  77.      * @param aTextBuffer  on return contains the text of this component
  78.      * @param aBufferSize  the size of the buffer passed in
  79.      * @param aActualSize  the number of char copied
  80.      * @result NS_Ok if no errors
  81.      *
  82.      */
  83.  
  84.     NS_IMETHOD GetText(nsString &aTextBuffer, PRUint32 aBufferSize, PRUint32& aActualSize) = 0;
  85.  
  86.     /**
  87.      * Set the text of this component.
  88.      *
  89.      * @param   aText -- an object containing a copy of the text
  90.      * @return  the number of chars in the text string
  91.      * @result NS_Ok if no errors
  92.      *
  93.      */
  94.  
  95.     NS_IMETHOD SetText(const nsString &aText, PRUint32& aActualSize) = 0;
  96.  
  97.     /**
  98.      * Insert text into this component.
  99.      * When aStartPos and aEndPos are a valid range this function performs a replace.
  100.      * When aStartPos and aEndPos are equal this function performs an insert.
  101.      * When aStartPos and aEndPos are both -1 (0xFFFFFFFF) this function performs an append.
  102.      * If aStartPos and aEndPos are out of range they are rounded to the closest end.
  103.      *
  104.      * @param   aText     the text to set
  105.      * @param   aStartPos starting position for inserting text
  106.      * @param   aEndPos   ending position for inserting text
  107.      * @result NS_Ok if no errors
  108.      */
  109.  
  110.     NS_IMETHOD InsertText(const nsString &aText, PRUint32 aStartPos, PRUint32 aEndPos, PRUint32& aActualSize) = 0;
  111.  
  112.     /**
  113.      * Remove any content from this text widget
  114.      * @result NS_Ok if no errors
  115.      */
  116.  
  117.     NS_IMETHOD RemoveText(void) = 0;
  118.  
  119.     /**
  120.      * Indicates a password will be entered. 
  121.      *
  122.      * @param aIsPassword PR_TRUE shows contents as asterisks. PR_FALSE shows
  123.      * contents as normal text.
  124.      * @result NS_Ok if no errors
  125.      */
  126.     
  127.     NS_IMETHOD SetPassword(PRBool aIsPassword) = 0;
  128.  
  129.     /**
  130.      * Sets the maximum number of characters the widget can hold 
  131.      *
  132.      * @param aChars maximum number of characters for this widget. if 0 then there isn't any limit
  133.      * @result NS_Ok if no errors
  134.      */
  135.     
  136.     NS_IMETHOD SetMaxTextLength(PRUint32 aChars) = 0;
  137.  
  138.  
  139.     /**
  140.      * Set the text widget to be read-only
  141.      *
  142.      * @param  aReadOnlyFlag PR_TRUE the widget is read-only,
  143.      *         PR_FALSE indicates the widget is writable. 
  144.      * @param  PR_TRUE if it was read only. PR_FALSE if it was writable           
  145.      * @result NS_Ok if no errors
  146.      */
  147.  
  148.     NS_IMETHOD SetReadOnly(PRBool aNewReadOnlyFlag, PRBool& aOldReadOnlyFlag) = 0;
  149.     
  150.     /**
  151.      * Select all of the contents
  152.      * @result NS_Ok if no errors
  153.      */
  154.  
  155.     NS_IMETHOD SelectAll() = 0;
  156.  
  157.     /**
  158.      * Set the selection in this text component
  159.      * @param aStartSel starting selection position in characters
  160.      * @param aEndSel ending selection position in characters 
  161.      * @result NS_Ok if no errors
  162.      */
  163.  
  164.     NS_IMETHOD SetSelection(PRUint32 aStartSel, PRUint32 aEndSel) = 0;
  165.  
  166.     /**
  167.      * Get the selection in this text component
  168.      * @param aStartSel starting selection position in characters
  169.      * @param aEndSel ending selection position in characters 
  170.      * @result NS_Ok if no errors
  171.      */
  172.  
  173.     NS_IMETHOD GetSelection(PRUint32 *aStartSel, PRUint32 *aEndSel) = 0;
  174.  
  175.     /**
  176.      * Set the caret position
  177.      * @param aPosition caret position in characters
  178.      * @result NS_Ok if no errors
  179.      */
  180.  
  181.     NS_IMETHOD SetCaretPosition(PRUint32 aPosition) = 0;
  182.  
  183.     /**
  184.      * Get the caret position
  185.      * @return caret position in characters
  186.      * @result NS_Ok if no errors
  187.      */
  188.  
  189.     NS_IMETHOD GetCaretPosition(PRUint32& aPosition) = 0;
  190.  
  191. };
  192.  
  193. #endif // nsITextWidget_h__
  194.  
  195.